<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<style>
			html,body {
						height: 100%;
						margin: 0px;
						font-family:PingFang-SC-Medium;
						padding: 0px;
					}
					.mui-bar{
						background: #FFFFFF;
					}
					
				.mui-titles{
					position: relative;
					float: right;
				}
				.mui-content{
					position: relative;
					float: left;
					width: 100%;
					padding: 10px  0px;
					display: inline-block;
					background: #FFFFFF;
				}		
				.biaoti{
					position: relative;
					float: left;
					width: calc(100% - 44px);
					height: 100%;
					display: flex;
					justify-content: space-around;
					padding-top: 5px;
					box-sizing: border-box;
				}
				
				.biaoti>div{
					width: 64px;
					height: 35px;
					font-size:15px;
		            font-weight:bold;
		            color:rgba(255,255,255,1);
					line-height: 35px;
					box-sizing: border-box;
				}
			.tiactive{
					border-bottom: 2px  solid #FFFFFF;
			}
				
				.mui-bar-nav>img:nth-child(1){
					position: relative;
					float: left;
					width: 20px;
					height: 27px;
					margin-top: 10px;
				}
				.mynews{
					position: absolute;
					width: 22px;
					height: 100%;
					right: 15px;
					z-index: 10;
				}
				.mynews>img:nth-child(1){
					width: 22px;
					height: 22px;
					margin-top: 10px;
				}
				.mynews>img:nth-child(2){
						width: 7px;
						height: 7px;
						position: absolute;
						top: 10px;
						right: 0px;
				}
					
				a{
					color:rgba(51,51,51,1);
				}
				a:active{
						color:rgba(51,51,51,1);
					}
					
				.dans{
					position: relative;
					float: left;
					width: 100%;
					border-bottom: 7px  solid  rgba(248,248,248,1);
					padding:15px  14px ;
					box-sizing: border-box;
				}	
			.dans>div:nth-child(1){
				position: relative;
				float: left;
				width: 100%;
				height: 19px;
			}	
			.dans>div:nth-child(1)>div:nth-child(1){
				position: relative;
				float: left;
				width: 60px;
				height: 19px;
				 line-height: 19px;
				font-size:13px;
                font-weight:500;
                color:rgba(51,51,51,1);
			}	
			.dans>div:nth-child(1)>div:nth-child(2){
				position: relative;
				float: left;
				width: 60px;
				height: 19px;
				 line-height: 19px;
				font-size:13px;
			    font-weight:500;
			    color:rgba(51,51,51,1);
			}	
			.dans>div:nth-child(1)>div:nth-child(3){
					position: relative;
					float: left;
					width: calc(100% - 120px);
					height: 19px;
					 line-height: 19px;
					font-size:13px;
				    font-weight:500;
				    color:rgba(51,51,51,1);
				}
					
				.dans>div:nth-child(2){
					position: relative;
					float: left;
					width: 100%;
					margin-top: 10px;
					border-bottom:  1px  solid rgba(248,248,248,1);
border-radius:1px;
padding-bottom: 10px;
				}	
				.dans>div:nth-child(2)>div:nth-child(1){
					position: relative;
					float: left;
					width: 60px;
					height: 100%;
					 line-height: 19px;
					font-size:13px;
				    font-weight:500;
				    color:rgba(51,51,51,1);
				}	
				.dans>div:nth-child(2)>div:nth-child(2){
					position: relative;
					float: left;
					height: 100%;
					width: calc(100% - 60px);
					 line-height: 19px;
					font-size:13px;
				    font-weight:500;
				    color:rgba(51,51,51,1);
				}		
			.dans>div:nth-child(3){
					position: relative;
					float: left;
					width: 100%;
					height:40px;
				}		
				.dans>div:nth-child(3) >.mui-radio{	
					position: relative;
					width: 50%;
					left: 0px!important;
					height: 40px;
					box-sizing: border-box;
					clear: none;
					float: left;
					padding-top: 5px;
				}
				input[type=radio]{
					left:0px!important;
						margin-top: 5px;
				}
				
				.mui-radio.mui-left label {
					padding-left: 33px;
			     	font-size:14px;
				}
				.mui-checkbox input[type=checkbox]:checked:before, .mui-radio input[type=radio]:checked:before{
					color: red;
				}
					.dans>div:nth-child(3)>div:nth-child(2){
						position: relative;
						float: right;
						width: 50%;
						height: 40px;
						margin-top: 12px;
					}
				.dans>div:nth-child(3)>div:nth-child(2)>div{
					position: relative;
					float: right;
					width: 60px;
					height: 26px;
					border:1px solid rgba(223,223,223,1);
                    border-radius:3px;
					text-align: center;
					font-size:14px;
                     font-weight:500;
                     color:rgba(153,153,153,1);
                     line-height:26px;
					 margin-right: 15px;
				}
				.newadd{
					position: absolute;
					right: 15px;
					line-height: 44px;
					font-size: 16px;
				}
				button{
					position: relative;
					float: left;
					font-size:14px;
					color: red;
				}
		</style>
	</head>

	<body contextmenu="return false;">
    <header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1  class="mui-title">我的收货地址</h1>
			<div class="newadd">新增</div> 
   </header>		
		<div class="mui-content"  id="content">
		      	<!--  -->
					<div class="dans">
						<div><div>收货人:</div><div>张雪</div><div>15388190321</div></div>
						<div><div>收货地址</div><div>四川省成都市青羊区太升南路199号</div></div>
						<div>
							<div class="mui-input-row mui-radio mui-left">
									<label>
										<div>设置为默认地址</div>
									</label>
									<input name="radio1" type="radio">
									
							</div>
							<div><div class="delete">删除</div><div class="update">编辑</div></div>
						</div>
					</div>
					
					<!--  -->
						<!-- <div class="dans">
						<div><div>收货人:</div><div>张雪</div><div>15388190321</div></div>
						<div><div>收货地址</div><div>四川省成都市青羊区太升南路199号</div></div>
						<div>
							<div class="mui-input-row mui-radio mui-left">
									<label>设为默认地址</label>
									<input name="radio1" type="radio"    >
							</div>
							<div><div class="delete">删除</div><div class="update">编辑</div></div>
						</div>
					</div> -->
					
		</div>
	</body>
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript" charset="utf-8">
			window.addEventListener('refresh', function(e){//执行刷新
			window.location.reload();
			});
			mui.plusReady(function () {
			     // mui.init({})
			    var url = plus.storage.getItem('url');
				var user = plus.storage.getItem('user');
				user = JSON.parse(user);
				$.post(url+'/juyou/address/getaddress',{token:user.token},function(res){
					if(res.code==200){
						var str = '';
						$.each(res.data,function(i,v){
							if(v.status==1){
								str+='<div class="dans">'+
									'<div><div>收货人:</div><div>'+v.name+'</div><div>'+v.phone+'</div></div>'+
									'<div><div>收货地址</div><div>'+v.shen+v.shi+v.xian+v.dir+'</div></div>'+
									'<div>'+
										'<div class="mui-input-row mui-radio mui-left">'+
												'<label>设为默认地址</label>'+
												'<input name="radio1" type="radio" value="'+v.id+'" checked>'+
										'</div>'+
										'<div><div class="delete" data-id="'+v.id+'">删除</div><div class="update" data-id="'+v.id+'">编辑</div></div>'+
									'</div>'+
								'</div>';
							}else{
								str+='<div class="dans">'+
									'<div><div>收货人:</div><div>'+v.name+'</div><div>'+v.phone+'</div></div>'+
									'<div><div>收货地址</div><div>'+v.shen+v.shi+v.xian+v.dir+'</div></div>'+
									'<div>'+
										'<div class="mui-input-row mui-radio mui-left">'+
												'<label>设为默认地址</label>'+
												'<input name="radio1" value="'+v.id+'" type="radio">'+
										'</div>'+
										'<div><div class="delete" data-id="'+v.id+'">删除</div><div class="update" data-id="'+v.id+'">编辑</div></div>'+
									'</div>'+
								'</div>';
							}
							
						})
						$("#content").empty();
						$("#content").append(str);
						mui.init({})
						//点击设为默认
						mui(".mui-radio").on('tap','input',function(){
							var id = $(this).val();
							plus.nativeUI.showWaiting();
							$.post(url+'/juyou/address/statusddress',{id:id,token:user.token},function(){
								plus.nativeUI.closeWaiting();
								if(res.code==200){
									mui.toast('设置成功');
								}else{
									mui.toast(res.msg);
									window.location.reload();
									
								}
							})
						})
						
						// 新增收货地址
						 mui(".mui-bar-nav").on("tap",".newadd",function(){
						mui.openWindow({
							url:'huaddadress.html',
							id:'huaddadress.html'
							})		 
						 })
						 mui("#content").on("tap",".delete",function(){
							 var id = $(this).attr('data-id');
							mui.confirm('你确定要删除吗？','提示',['取消','确定'],function(event){
								if(event.index==1){
									// plus.nativeUI.showWaiting();
									$.post(url+'/juyou/address/deladdress',{token:user.token,id:id},function(res){
										// plus.nativeUI.closeWaiting();
										if(res.code==200){
											mui.toast(res.msg);
											setTimeout(function(){
												window.location.reload();
											},1500)
										}else{
											mui.toast(res.msg);
										}
									})
								}
							})
						  })
						// 编辑地址 
						  mui("#content").on("tap",".update",function(){
							  var id = $(this).attr('data-id');
							  // mui.alert(id);
						 mui.openWindow({
						 	url:'huupdateaddress.html',
						 	id:'huupdateaddress.html',
							extras: {
								addressid:id,
								},
						 	})		 
						  })
					}else{
						mui.toast(res.msg);
					}
				})
				  
				  
			})
		</script>
</html>
